package genetic;

import genetic.treenodes.Addition;
import genetic.treenodes.Constant;
import genetic.treenodes.Division;
import genetic.treenodes.IfEqualThenElse;
import genetic.treenodes.IfGreaterThenElse;
import genetic.treenodes.Multiplication;
import genetic.treenodes.Sinus;
import genetic.treenodes.Subtraction;
import genetic.treenodes.Variable;

import java.util.ArrayList;
import java.util.Random;

public class T08_optimizationTest1 {

	public static void main(String[] args) {
		ArrayList<GPTreeNode> functionSet = new ArrayList<GPTreeNode>();
		ArrayList<GPTreeNode> terminalSet = new ArrayList<GPTreeNode>();
		
		functionSet.add(new Addition());
		functionSet.add(new Subtraction());
		functionSet.add(new Multiplication());
		functionSet.add(new Division());
		functionSet.add(new Sinus());
		functionSet.add(new IfEqualThenElse());
		functionSet.add(new IfGreaterThenElse());
		
		DataSet inputAndTargetData = new DataSet();
		//TODO Biodiversity berechnen
		inputAndTargetData.loadFromExcel("testdata2.xls", "x3");
		inputAndTargetData.loadFromExcel("testdata2.xls", "y3");
		terminalSet.add(new Variable("x3", inputAndTargetData));
		Random rd = new Random();
		terminalSet.add(new Constant(rd.nextDouble()));
		terminalSet.add(new Constant(rd.nextDouble()));
		terminalSet.add(new Constant(rd.nextDouble()*5));
		terminalSet.add(new Constant(rd.nextDouble()*10));

		Population pop = new Population(functionSet, terminalSet, inputAndTargetData);
		
		pop.createRandom(100, 3);
		
		for (int i=0; i<20; i++) {
			pop.evolveNewGeneration();
		}
	}
}
